home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / piblist.arc / PROMPT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-03-28  |  4.0 KB  |  103 lines

  1. (*----------------------------------------------------------------------*)
  2. (*                   Prompt --- Prompt for Command Entry                *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Prompt;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*   Procedure:   Prompt                                                *)
  10. (*                                                                      *)
  11. (*   Purpose:     Prompts for, reads, parses, and executes command.     *)
  12. (*                                                                      *)
  13. (*   Calling sequence:                                                  *)
  14. (*                                                                      *)
  15. (*      Prompt;                                                         *)
  16. (*                                                                      *)
  17. (*   Calls:  Position                                                   *)
  18. (*           Issue_Prompt                                               *)
  19. (*           Find_Line                                                  *)
  20. (*           Display_Menu                                               *)
  21. (*           Read_Command                                               *)
  22. (*           Skipbl                                                     *)
  23. (*           GoToXY                                                     *)
  24. (*           Sound                                                      *)
  25. (*           Delay                                                      *)
  26. (*           NoSound                                                    *)
  27. (*                                                                      *)
  28. (*----------------------------------------------------------------------*)
  29.  
  30. VAR
  31.    legal:    BOOLEAN;
  32.    question: BOOLEAN;
  33.    c:        CHAR;
  34.  
  35. BEGIN (* Prompt *)
  36.  
  37.    REPEAT
  38.  
  39.       legal    := TRUE;
  40.       question := FALSE;
  41.                                    (* Issue command prompt *)
  42.       Issue_Prompt;
  43.                                    (* Read command *)
  44.       Read_Command;
  45.                                    (* Skip leading blanks *)
  46.       Skipbl;
  47.                                    (* Null line -- go to next screen *)
  48.  
  49.       IF Command[Cind] = NUL THEN
  50.          Find_Line( bot^.lnum + 1 )
  51.  
  52.                                    (* Look for EXIT *)
  53.  
  54.       ELSE IF Command[Cind] IN ['E','e','?'] THEN
  55.          BEGIN
  56.             c    := Command[Cind];
  57.             Cind := Cind + 1;
  58.             IF Command[Cind] IN ['X','x'] THEN
  59.                BEGIN
  60.                   Cind := Cind + 1;
  61.                   IF Command[Cind] IN ['I','i'] THEN
  62.                      BEGIN
  63.                         Cind := Cind + 1;
  64.                         IF Command[Cind] IN ['T','t'] THEN
  65.                            Cind := Cind + 1
  66.                      END
  67.                END;
  68.                                    (* Skip any trailing blanks *)
  69.             Skipbl;
  70.                                    (* If legal command, we've reached EOLN *)
  71.  
  72.             Legal := Command[Cind] = NUL;
  73.  
  74.                                    (* If legal command, then execute it. *)
  75.             IF Legal THEN
  76.  
  77.                CASE c OF
  78.  
  79.                   'E', 'e': done := TRUE;
  80.  
  81.                   '?':  (* Display Help *)
  82.                      BEGIN
  83.                         Display_Menu;
  84.                         question := TRUE;
  85.                      END
  86.                END
  87.          END
  88.       ELSE                         (* If not EXIT or ?, check if other *)
  89.                                    (* legal command                    *)
  90.          Position( legal );
  91.  
  92.                                    (* Issue beep if not legal command  *)
  93.       IF NOT legal THEN
  94.          BEGIN
  95.             Sound( 440 );
  96.             Delay( 500 );
  97.             NoSound;
  98.          END;
  99.  
  100.    UNTIL ( legal AND ( NOT question ) );
  101.  
  102. END   (* Prompt *);
  103.